package top.datacluster.basic.offer;

public class InterviewQuestion3 {

    public static void main(String[] args) {
        int[] a = new int[]{3, 2, 0, 1, 4, 5};
        System.out.println(findRepeat(a));
    }

    public static Integer findRepeat(int[] array){
        if (array == null){
            return null;
        }
        if (array.length == 1){
            return null;
        }
        for (int i = 0; i < array.length; i++){
            while (array[i] != i){
                if (array[i] == array[array[i]]){
                    return array[i];
                }
                int temp = array[array[i]];
                array[array[i]] = array[i];
                array[i] = temp;
            }
        }
        return null;
    }
}
